<?php

Class Cookie{

	function __construct() {

	}

	static public function set($name, $value, $expiry = 7, $path = '/', $domain = false)
	{

		if ($expiry === -1){
			$expiry = 1893456000; // Lifetime = 2030-01-01 00:00:00
		}else if(is_numeric($expiry)){
			$expiry = $expiry*86400 + time();
		}else{
			$expiry = strtotime($expiry);

		}
		$retval = setcookie($name, $value, $expiry, $path);
		$_COOKIE[$name] = $value;
	}
	static public function delete($name)
	{
		$retval = false;
		if (!headers_sent())
		{
			if (!isset($domain))
			$domain = $_SERVER['HTTP_HOST'];
			$retval = setcookie($name, '', time() - 3600);
			if ($retval)
			unset($_COOKIE[$name]);
		}
		return $retval;
	}

	static public function get($name){
		return $_COOKIE[$name];
	}

	static public function exists($name){
		if(isset($_COOKIE[$name])){
			return true;
		}
		return false;
	}
}